blob: b4d7d496c11a20de651229fd3f7c5afb3ca47d4c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import Qr from 'qrcode-base64';
import { get } from '$lib/utils';
import { redirect } from '@sveltejs/kit';
export async function load({ depends, params, url }) {
depends('app:invoice');
let { id } = params;
let invoice = await get(`/invoice?uuid=${id}`);
let { amount, received, pending } = invoice;
amount = parseInt(amount);
let paid = (!amount && (received || pending)) || (amount > 0 && received + pending >= amount);
if (paid && !url.pathname.endsWith('paid')) throw redirect(307, `/invoice/${id}/paid`);
let sm = Qr.drawImg(invoice.text, { size: 300 });
// let lg = Qr.drawImg(invoice.text, { size: 1200 });
return { id, invoice, sm, lg: sm };
}
|